from flask import Flask, session, request
import logging
import time

from blueprints.home.home import home_bp
from blueprints.exercises.exercises import exercises_bp
from blueprints.users.users import users_bp
from blueprints.admin import admin_bp
from blueprints.upload_exam import upload_exam_bp

app = Flask(__name__)
app.secret_key = 'your-secret-key-here'  # 请在实际生产环境中使用更安全的密钥
app.register_blueprint(home_bp)
app.register_blueprint(exercises_bp)
app.register_blueprint(users_bp)
app.register_blueprint(admin_bp)
app.register_blueprint(upload_exam_bp)

@app.context_processor
def inject_user():
    user = session.get('user', {'username': None, 'is_authenticated': False})
    return dict(current_user=user)
    

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)
